{% extends "orga/base.html" %}

{% load i18n %}
{% load rules %}

{% block extra_title %}{{ page_obj.paginator.count }} {% blocktranslate trimmed count count=page_obj.paginator.count %}submitter{% plural %}submitters{% endblocktranslate %} :: {% endblock extra_title %}

{% block content %}
    <div class="d-md-flex justify-content-between">
        <h2>
            {{ page_obj.paginator.count }}
            {% blocktranslate trimmed count count=page_obj.paginator.count %}
                submitter
            {% plural %}
                submitters
            {% endblocktranslate %}
        </h2>
        {% include "orga/event/component_link.html" %}
    </div>

    {% include "common/includes/search_form.html" %}

    {% if filter_form.is_valid and filter_form.cleaned_data.question %}
        <p class="text-muted ml-2">
            <span class="fa fa-filter"></span>
            {% blocktranslate trimmed with question=filter_form.cleaned_data.question.question %}
                List filtered by responses to custom field “{{ question }}”.
            {% endblocktranslate %}
            <a href="{% querystring question="" answer="" answer__options="" %}" class="text-muted">
                <span class="fa fa-times"></span>
                {% translate "Remove filter" %}
            </a>
        </p>
    {% endif %}

    {% has_perm "base.mark_arrived_speakerprofile" request.user request.event as can_mark_speaker %}
    <div class="table-responsive-md">
        <table class="table table-sm table-flip table-sticky">
            <thead>
                <tr>
                    <th>{% translate "Name" %}</th>
                    <th class="numeric">{% translate "Accepted Proposals" %}</th>
                    <th class="numeric">{% translate "Proposals" %}</th>
                    <th></th>
                </tr>
            </thead>
            <tbody>
                {% for profile in speakers %}
                    <tr>
                        <td>
                            <a href="{{ profile.orga_urls.base }}">
                                {% include "orga/includes/user_name.html" with user=profile.user %}
                            </a>
                        </td>
                        <td class="numeric">{{ profile.accepted_submission_count }}</td>
                        <td class="numeric">{{ profile.submission_count }}</td>
                        <td class="text-right">
                            {% if profile.accepted_submission_count %}
                                {% if can_mark_speaker %}
                                    <a class="btn btn-sm btn-{{ profile.has_arrived|yesno:"success,info" }}" href="{{ profile.orga_urls.toggle_arrived }}?from=list">
                                        {% if profile.has_arrived %}
                                            {% translate "Mark speaker as not arrived" %}
                                        {% else %}
                                            {% translate "Mark speaker as arrived" %}
                                        {% endif %}
                                    </a>
                                {% else %}
                                    {% if profile.has_arrived %}
                                        <a><i class="fa fa-check"></i> {% translate "Arrived" %}</a>
                                    {% else %}
                                        <a><i class="fa fa-times"></i> {% translate "Not arrived" %}</a>
                                    {% endif %}
                                {% endif %}
                                </td>
                            {% endif %}
                        </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>

    {% include "orga/includes/pagination.html" %}

{% endblock content %}
